AutomatDetailsAjaxView = new function(){
    this.init = _init;
    
    var _initData;
    
    function _init(initData){
        _initData = initData;
        _setEvents();
    }
    
    function _setEvents(){
        $('#close-button-img, #delete-automat-button-img')
        .mouseover(function(){
            $(this).css('width','+=4px').css('height','+=4px')
                .attr('left','-=2px').attr('top','-=2px');
        }).mouseout(function(){
            $(this).css('width','-=4px').css('height','-=4px');
        });
        $('#close-button-img').click(function(){
            $('#details').animate({'opacity' : 0},function(){window.location = _initData.reloadUrl;});
        });
        $('#delete-automat-button-img').click(function(){
            if(!confirm('Delete automat?')){
                return;
            }
            $.ajax({
                url : _initData.deleteUrl,
                data : {'automatId':$('[name="AutomatId"]').val()},
                success : function(resp){window.location = _initData.reloadUrl;}
            });
            
        });
        
        $('#wares-edit-button').click(function(){
            window.location = _initData.editWaresUrl + '?id=' + $('[name="AutomatId"]').val();
        });
    }
    
}